<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    /* 
     集合
      n       n=0 1 2 3 ...   [0 1 2 3 4...] 
      n+1     n=0 1 2 3 ...   [1 2 3 4 5...]
      2n+1    n=0 1 2 3 ...   [1 3 5 7 9...] 奇数
      2n+2    n=0 1 2 3 ...   [2 4 6 8 10...] 偶数
      3n+2    n=0 1 2 3 ...   [5 8 11 ...] 偶数
    */
    /* div>p:nth-child(2) {
      color: red;
    } */
    div>p:nth-child(2n+1) {
      color: red;
    }
  </style>
</head>

<body>
  <div>
    <p>p1</p>
    <p>p2</p>
    <p>p3</p>
    <p>p4</p>
    <p>p5</p>
    <p>p6</p>
    <p>p7</p>
    <p>p8</p>
  </div>
</body>

</html>